﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace tomssoftware.Html
{
    internal static class HtmlMap
    {
        private static readonly Dictionary<string, ElementId> strToId;

        static HtmlMap()
        {

            strToId = new Dictionary<string, ElementId>();
            for (int i = (int)ElementId.unknown; i < (int)ElementId.max; i++)
            {
                ElementId id = (ElementId)i;
                strToId.Add(id.ToString().ToLower(), id);
            }
        }

        public static ElementId ToId(this string elementName)
        {
            ElementId id;
            if (strToId.TryGetValue(elementName.ToLower(), out id)) return id;
            return ElementId.unknown;
        }
    }
}
